import mitt, { Emitter } from 'mitt'
import { Advise, Notice, Vol } from '@/ts/type'
import { DealHealth } from '@/ts/type/Health'
import { Type } from '@/ts/type/Goods'
import { ClaimDto, DealClaim } from '@/ts/type/Claim'

// 事件总线类型
type Events = {
	noticeSearchForm: Notice
	noticeOpen: boolean
	collapseVal: boolean
	adviseSearch: Advise
	reGetAdvise: boolean
	addVolForm: Vol
	searchVolForm: Vol
	searchVol: boolean
	searchHealthForm: DealHealth
	searchHealth: boolean
	searchTypeForm: Type
	searchType: boolean
	addGoods: { bool: boolean }
	updateGoods: { bool: boolean, goodsId: number }
	claimDrawer: { bool: boolean, ClaimDtoVal: ClaimDto } // 物资抽屉的传值
	searchClaim: { bool: boolean, dealClaimVal?: DealClaim } // 搜索物资申领的传值
	searchUser: { bool: boolean, uname?: string } // 用户搜索传值
	addUser: { bool: boolean }
	updateUser: { userId: number }
	searchUserHealth: { bool: boolean, uHealthVal?: DealHealth }
}

// 提供泛型参数让 emitter 能自动推断参数类型
export const EventBus: Emitter<Events> = mitt<Events>()

